﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
		<title>NLayer Architecture - N 层体系结构</title>
		<link type="text/css" rel="stylesheet" href="bootstrap.min.css" />
		</head>

	<body>

		<div class="document-contents">

			<h3 id="DocIntroLayers">Introduction - 介绍</h3>
			<p>Layering of an application's codebase is a widely accepted technique to help
reduce complexity and improve code reusability. To achieve layered
architecture, ASP.NET Boilerplate follows the principles of <strong>Domain Driven
Design</strong>.</p>
			<p class="translation">应用程序的代码级分层是一个被广泛接受的技巧，可以帮助降低复杂度和提高代码复用性。为了实现分层架构，ABP 遵循以下<strong>领域驱动设计</strong>原则。</p>
			<h3>Domain Driven Design Layers - 领域驱动设计层次</h3>
			<p>There are four fundamental layers in Domain Driven Design (DDD):</p>
			<p class="translation">在领域驱动设计（DDD）中有四个基本层：</p>
			<ul>
				<li>
					<strong>Presentation Layer</strong>: Provides an interface to the user.
	Uses the Application Layer to achieve user interactions.
				</li>
				<p class="translation"><strong>表现层</strong>：提供了用户访问的接口，使用应用层实现用户交互。</p>
				<li>
					<strong>Application Layer</strong>: Mediates between the Presentation
	and Domain Layers. Orchestrates business objects to perform specific
	application tasks.
				</li>
				<p class="translation"><strong>应用层</strong>：表现层和领域层之间的媒介。组织业务对象来执行特定的应用任务。</p>
				<li>
					<strong>Domain Layer</strong>: Includes business objects and their rules.
	This is heart of the application.
				</li>
				<p class="translation"><strong>领域层</strong>：包括业务对象及它们的规则。这是应用程序的核心。</p>
				<li>
					<strong>Infrastructure Layer</strong>: Provides generic 
					technical capabilities that support higher layers mostly 
					using 3rd-party libraries.
				</li>
				<p class="translation"><strong>基础设施层</strong>：为支持更高层提供了通用的技术能力，大部分使用第三方库。</p>
			</ul>
			<h3>ASP.NET Boilerplate Application Architecture Model - ASP.NET Boilerplate 应用程序体系结构模型</h3>
			<p>In addition to DDD, there are also other logical and physical 
			layers in a modern architected application. The model below is 
			suggested and implemented for ASP.NET Boilerplate applications. 
			ASP.NET Boilerplate not only makes to implement this model easier by 
			providing base classes and services, but also provides
			<a href="/Templates">startup templates</a> to directly start with 
			this model.</p>
			<p class="translation">除了 DDD 外，现在体系结构应用程序中还存在其它逻辑和物理层。这个模型是被 ASP.NET Boilerplate 应用程序建议并实现的。
				ASP.NET Boilerplate 不仅为实现这个模型提供了方便的基类和服务，而且提供了<a href="/Templates">启动模板</a>来直接启动这个模型。
			</p>
			<p>
			<a href="https://raw.githubusercontent.com/aspnetboilerplate/aspnetboilerplate/master/doc/WebSite/images/abp-nlayer-architecture.png" target="_blank">
			<img class="img-thumbnail" alt="ASP.NET Boilerplate N 层体系结构" height="1236" src="images/abp-nlayer-architecture.png" width="1220" /></a></p>
		</div>
		<h4>Client Applications - 客户端应用程序</h4>
		<p>These are remote clients uses the application as a service via HTTP 
		APIs (API Controllers, <a href="OData-Integration.html">OData</a> 
		Controllers, maybe GraphQL endpoint). A remote client can be a SPA, a 
		mobile application or a 3rd-party consumer. <a href="Localization.html">
		Localization</a> and <a href="Navigation.html">Navigation</a> can be 
		done inside this applications. </p>
		<p class="translation">
			这些远程客户端通过 HTTP API（API 控制器，<a href="OData-Integration.html">OData</a> 控制器，或 GraphQL 终结点）使用应用程序作为服务。
			一个远程客户端可以是 SPA，移动应用程序或第三方消费者。
			<a href="Localization.html">本地化</a>和<a href="Navigation.html">导航</a>可以被应用程序内部完成。
		</p>
		<h4>Presentation Layer - 表现层</h4>
		<p>ASP.NET [Core] MVC (Model-View-Controller) can be considered as the 
		presentation layer. It can be a physical layer (uses application via 
		HTTP APIs) or a logical layer (directly injects and uses
		<a href="Application-Services.html">application services</a>). In either 
		case it can include <a href="Localization.html">Localization</a>,
		<a href="Navigation.html">Navigation</a>,
		<a href="Object-To-Object-Mapping.html">Object Mapping</a>,
		<a href="Caching.html">Caching</a>, <a href="Setting-Management.html">
		Configuration Management</a>, <a href="Audit-Logging.html">Audit Logging</a> 
		and so on. It should also deal with <a href="Authorization.html">
		Authorization</a>, <a href="Abp-Session.html">Session</a>,
		<a href="Feature-Management.html">Features</a> (for
		<a href="Multi-Tenancy.html">multi-tenant</a> applications) and
		<a href="Handling-Exceptions.html">Exception Handling</a>.</p>
		<p class="translation">
			ASP.NET [Core] MVC (Model-View-Controller) 可以被考虑作为表现层。
			它可以是一个物理层（通过 HTTP API 使用的应用程序）或一个逻辑层（直接注入和使用<a href="Application-Services.html">应用服务</a>）。
			在这两种情况下，它可以包含<a href="Localization.html">本地化</a>，<a href="Navigation.html">导航</a>，<a href="Object-To-Object-Mapping.html">对象映射</a>，
			<a href="Caching.html">缓存</a>，<a href="Setting-Management.html">配置管理</a>，<a href="Audit-Logging.html">审计日志</a>等。
			它还应该处理<a href="Authorization.html">授权</a>，<a href="Abp-Session.html">会话</a>，<a href="Feature-Management.html">特性</a>（用于<a href="Multi-Tenancy.html">多租户</a>应用程序）以及<a href="Handling-Exceptions.html">异常处理</a>。
		</p>
		<h4>Distributed Service Layer - 分布式服务层</h4>
		<p>This layer is used to serve application/domain functionality via 
		remote APIs like REST, OData, GraphQL... They don&#39;t contain business 
		logic but only translates HTTP requests to domain interactions or can 
		use application services to delegate the operation. This layer generally 
		include <a href="Authorization.html">Authorization</a>,
		<a href="Caching.html">Caching</a>,
		<a href="Audit-Logging.html">Audit Logging</a>, <a href="Object-To-Object-Mapping.html">Object Mapping</a>,
		<a href="Handling-Exceptions.html">Exception Handling</a>,
		<a href="Abp-Session.html">Session</a> and so on... </p>
		<p class="translation">
			这个层是被用来为远程 API （像 REST，OData，GraphQL）提供应用/领域功能。
			它们不包含业务逻辑，仅传输 HTTP 请求到领域交互，或可以使用应用服务来委托操作。
			这个层一般包括<a href="Authorization.html">授权</a>，<a href="Caching.html">缓存</a>，<a href="Audit-Logging.html">审计日志</a>，
			<a href="Object-To-Object-Mapping.html">对象映射</a>，<a href="Handling-Exceptions.html">异常处理</a>，<a href="Abp-Session.html">会话</a>等...
		</p>
		<h4>Application Layer - 应用层</h4>
		<p>Application layer mainly includes <a href="Application-Services.html">
		Application Services</a> those use domain layer and domain objects (<a href="Domain-Services.html">Domain 
		Services</a>, <a href="Entities.html">Entities</a>...) to perform 
		requested application functionalities. It uses
		<a href="Data-Transfer-Objects.html">Data Transfer Objects</a> to get 
		data from and to return data to presentation or distributed service 
		layer. It can also deal with <a href="Authorization.html">Authorization</a>,
		<a href="Caching.html">Caching</a>, <a href="Audit-Logging.html">Audit 
		Logging</a>, <a href="Object-To-Object-Mapping.html">Object Mapping</a>,
		<a href="Abp-Session.html">Session</a> and so on...</p>
		<p class="translation">
			应用层主要包括<a href="Application-Services.html">应用服务</a>，它使用领域层及领域对象（<a href="Domain-Services.html">领域服务</a>，<a href="Entities.html">实体</a>...）来执行应用功能请求。
			我使用<a href="Data-Transfer-Objects.html">数据传输对象</a>来获取数据，并返回数据到表现层或分布式服务层。
			它也可以处理<a href="Authorization.html">授权</a>，<a href="Caching.html">缓存</a>，<a href="Audit-Logging.html">审计日志</a>，
			<a href="Object-To-Object-Mapping.html">对象映射</a>，<a href="Abp-Session.html">会话</a>等等...
		</p>
		<h4>Domain Layer - 领域层</h4>
		<p>This is the main layer that implements our domain logic. It includes
		<a href="Entities.html">Entities</a>, <a href="Value-Objects.html">Value 
		Objects</a>, <a href="Domain-Services.html">Domain Services</a> to 
		perform business/domain logic. It can also include
		<a href="Specifications.html">Specifications</a> and trigger
		<a href="EventBus-Domain-Events.html">Domain Events</a>. It defines 
		Repository Interfaces to read and persist entities from data source 
		(generally a DBMS).</p>
		<p class="translation">
			这是实现我们领域逻辑最主要的层。
			它包括用来执行业务/领域逻辑的<a href="Entities.html">实体</a>，<a href="Value-Objects.html">值对象</a>，<a href="Domain-Services.html">领域服务</a>。
			它也可以包括<a href="Specifications.html">规格</a>和触发<a href="EventBus-Domain-Events.html">领域事件</a>。
			它定义用来从数据源（一般为 DBMS）读取和持久化实体的仓库接口。
		</p>
		<h4>Infrastructure Layer - 基础设施层</h4>
		<p>Infrastructure layer makes other layers working: It implements 
		repository interfaces (using <a href="Entity-Framework-Core.html">Entity 
		Framework Core</a> for example) to actually work with a real database, it may 
		include integration to a vendor to <a href="Email-Sending.html">send 
		emails</a> and so on. This is not a strict layer below all layers, but 
		actually supports other layers by implementing 
		abstract concepts of them.</p>
		<p class="translation">
			基础设施层使用其它层发挥作用：它实现了仓库接口（例如使用 <a href="Entity-Framework-Core.html">Entity Framework Core</a>）来与真实数据库一起工作，它也可以集成一个提供商来<a href="Email-Sending.html">发送邮件</a>等。
			这不是严格意义上的其它层的低层，但实际上通过实现它们的抽象概念来支持其它层。
		</p>
	</body>

</html>
